package com.ssy.lingxi.marketing.model.constant;


import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 会员活动内部状态 - enum
 * @author fhj
 * @date 2021/06/24
 * @version 2.0.0
 */
public enum MerchantActivityInnerStatusEnum {
    ALL(0, "所有状态"),
    TO_BE_SUBMIT_EXAM(1, "待提交审核"),
    TO_BE_EXAMINE_1(2, "待审核(一级)"),
    EXAMINE_NO_PASS_1(3, "审核不通过(一级)"),
    TO_BE_EXAMINE_2(4, "待审核(二级)"),
    EXAMINE_NO_PASS_2(5, "审核不通过(二级)"),
    TO_BE_SUBMIT(6, "待提交"),
    /*22.1.20版已废除[废除平台审核]
    SUBMITTED(7, "已提交"),*/
    TO_BE_ONLINE(8, "待上线活动"),
    ONGOING(9, "已上线活动"),
    STOP(10, "已终止"),
    END(11, "已结束"),
    ;

    private final Integer code;
    private final String message;

    MerchantActivityInnerStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }


    public String getMessage() {
        return LanguageHolder.getName(this.getClass(), this.code);
    }

    /**
     * 根据code获取message
     * */
    public static String getMessage(Integer code) {
        return Arrays.stream(MerchantActivityInnerStatusEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getMessage();
    }

    /**
     * 获取所有
     * */
    public static List<Map<String, Object>> getAll() {
        return Arrays.stream(MerchantActivityInnerStatusEnum.values()).map(a -> {
            Map<String, Object> map = new HashMap<>();
            map.put("code", a.getCode());
            map.put("message", a.getMessage());
            return map;
        }).collect(Collectors.toList());
    }
}
